﻿<UserControl x:Class="NthDownload.Views.BandwidthProvidersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:behaviors="clr-namespace:NthDownload.Common.Interactivity.Behaviors;assembly=NthDownload.Common"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
            <Button x:Name="AddNewBandwidthProvider" Content="+" Margin="0,0,0,5"/>
        </StackPanel>

        <ListBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Profile.BandwidthProviders}" SelectionMode="Extended"
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
            <i:Interaction.Behaviors>
                <behaviors:ListBoxSelectedItemsBinder SelectedItems="{Binding SelectedBandwidthProviders, Mode=TwoWay}" />
                <behaviors:ListBoxScrollOffsetBinder VerticalOffset="{Binding VerticalOffset, Mode=TwoWay}" HorizontalOffset="{Binding HorizontalOffset, Mode=TwoWay}" />
            </i:Interaction.Behaviors>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <TextBlock Text="{Binding Name}" />
                            <TextBlock Text=" - " />
                            <TextBlock Text="{Binding BytesPerSecond}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button Content="Edit" cal:Message.Attach="[Event Click] = [Action EditBandwidthProvider($dataContext)]" Margin="0,0,5,0" 
                                    Style="{StaticResource ListBoxMouseOverButton}"/>
                            <Button Content="Remove" cal:Message.Attach="[Event Click] = [Action RemoveBandwidthProviders($dataContext)]" Margin="0,0,0,0" 
                                    Style="{StaticResource ListBoxMouseOverButton}"/>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
